<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class CKomentar extends DR_Controller 
{

	function __Construct()
	{
		parent::__Construct();
		
		$this->load->model("komentar");
		$this->load->model("user");		
		$this->load->model("yayasan");		
		$this->load->library("pagination");	
		
		$this->only_admin("admin/main/login");
	}
	
	function update()
	{
	}
	
	function solved()
	{
	}
	
	function index($offset=null,$field=null,$value=null)
	{
		$filter=null;
		if($field!=null & $value!=null){
			$offset = $this->uri->segment(7); 
			$config['uri_segment']=7;					
			$filter = "$field like '%$value%'";
			$config['base_url'] = site_url("/admin/ckomentar/index/0/$field/$value");
			$config['total_rows'] = $this->komentar->get_count($filter);			
			
			$data["filtered"] = true;
			
			//download filtered
			$this->session->set_flashdata("filter",$filter);			
			
		}
		else
		{
			$data["filtered"] = false;
			
			$offset = $this->uri->segment(4); 
			$config['uri_segment']=4;					
			$filter = array();
			$config['base_url'] = site_url('/admin/ckomentar/index/');
			$config['total_rows'] = $this->komentar->get_count($filter);			
		}
				
        $config['per_page'] = 20;
        $this->pagination->initialize($config);
        $paginator=$this->pagination->create_links();
		
		$data["offset"] = $offset;
		$this->komentar->set_default_order(array("tgl_komentar"=>"desc"));		
		$data['result'] = $this->komentar->get_paged($config['per_page'],$offset,$filter);
		$data['total_page'] = $paginator;
		
		$data["config"] = $config;
		//sekarang gunakan set view. agar content dirender didalam container
		$this->set_view("admin/header",'admin/komentar/list',$data);	
	}

}
?>